home *** CD-ROM | disk | FTP | other *** search
/ Aminet 19 / Aminet 19 (1997)(GTI - Schatztruhe)[!][Jun 1997].iso / Aminet / comm / thor / MDApprove.lha / Majordomo_approve.thor < prev    next >
Text File  |  1997-04-28  |  3KB  |  135 lines

  1. /* $VER: Majordomo_approve.thor 1.0 (28.4.97)
  2. **
  3. ** Author: Oliver Roberts
  4. ** E-Mail: Oliver@poboxes.com
  5. **    WWW: http://www.nanunanu.org/~oliver/
  6. **
  7. ** Brief Description:
  8. **
  9. ** Arexx script for Majordomo list owners.  Allows automatic handling of
  10. ** the most common messages that Majordomo will send you which require
  11. ** approval
  12. **
  13. ** Must be started from THOR.
  14. */
  15.  
  16. conf = 'EMail'                /* e-mail conference name */
  17.  
  18. /* Password configuration - entries should be in the following form */
  19.  
  20. password.donut_makers = 'BigSecret'
  21.  
  22.  
  23. /********************* DO NOT MODIFY BELOW HERE *************************/
  24. options results
  25.  
  26. thorport = address()
  27.  
  28. if ~show('p', 'BBSREAD') then do
  29.     address command
  30.         "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
  31.         "WaitForPort BBSREAD"
  32. end
  33.  
  34. address(thorport)
  35.  
  36. CURRENTMSG stem MSG
  37. if(rc ~= 0) then
  38. do
  39.     REQUESTNOTIFY TEXT '"No current message."' BT '"_Ok"'
  40.     exit
  41. end
  42.  
  43. bbs = MSG.BBSNAME
  44.  
  45. address(bbsread)
  46.  
  47. /* Get a unique message for the event */
  48.  
  49. UNIQUEMSGFILE bbsname '"'bbs'"' stem UNIQUEFILE
  50. if(rc ~= 0) then goto quit
  51.  
  52. /* Read the data on the message that is to be forwarded */
  53.  
  54. READBRMESSAGE bbsname '"'MSG.BBSNAME'"' confname '"'MSG.CONFNAME'"' msgnr MSG.MSGNR headstem HEADTAGS textstem TEXTTAGS 
  55. if(rc ~= 0) then goto quit
  56.  
  57. /* Setup message variables */
  58.  
  59. domain = right(HEADTAGS.FROMADDR,length(HEADTAGS.FROMADDR) - pos('@',HEADTAGS.FROMADDR))
  60. listname = left(word(HEADTAGS.SUBJECT,2),length(word(HEADTAGS.SUBJECT,2)))
  61. if (pos(':',listname) ~= 0) then do
  62.     listname = left(listname,pos(':',listname)-1)
  63. end
  64.  
  65. if (symbol('password.'listname) = "VAR") then do
  66.     passwd = value('password.'listname)
  67. end
  68. else do
  69.     passwd = ''
  70. end
  71.  
  72. if (passwd = '') then do
  73.     address(thorport)
  74.     REQUESTSTRING TITLE '"Enter password:"' BT '" _Ok | _Cancel "' MAXCHARS 20
  75.     if(rc ~= 0) then exit
  76.     passwd = result
  77. end
  78.  
  79. address(BBSREAD)
  80.  
  81. /* Create message file */
  82.  
  83. if(~open(fh, UNIQUEFILE.NAME, W)) then 
  84. do
  85.     address(thorport)
  86.     REQUESTNOTIFY TEXT '"Unable to open file:' UNIQUEFILE.NAME '"' BT '"_Ok"'
  87.     exit
  88. end
  89.  
  90. /* Build the message */
  91.  
  92. if (LEFT(HEADTAGS.SUBJECT,7) = 'BOUNCE ') then do
  93.     toaddress = listname || '@' || domain
  94.     call writeln(fh,'')
  95.     call writeln(fh, 'Approved: ' || passwd)
  96.     do n=1 to TEXTTAGS.TEXT.COUNT
  97.         call writeln(fh, TEXTTAGS.TEXT.n)
  98.     end
  99. end
  100.  
  101. if (LEFT(HEADTAGS.SUBJECT,8) = 'APPROVE ') then do
  102.     toaddress = 'majordomo@' || domain
  103.     do n=1 to TEXTTAGS.TEXT.COUNT
  104.         if ((compress(word(TEXTTAGS.TEXT.n,1),'09'x) = 'approve') & (word(TEXTTAGS.TEXT.n,2) = 'PASSWORD')) then do
  105.             call writeln(fh, 'approve ' || passwd || ' ' || right(TEXTTAGS.TEXT.n,length(TEXTTAGS.TEXT.n) - pos('PASSWORD',TEXTTAGS.TEXT.n) - 8))
  106.         end
  107.     end
  108. end
  109.  
  110. call close(fh)
  111.  
  112. /* Post it */
  113.  
  114. drop EVENT.
  115.  
  116. EVENT.SUBJECT = 'Re: '||HEADTAGS.SUBJECT
  117. EVENT.TOADDR = toaddress
  118. EVENT.CONFERENCE = conf
  119. EVENT.MSGFILE = UNIQUEFILE.FILEPART
  120.  
  121. WRITEBREVENT bbsname '"'bbs'"' event 0 stem EVENT
  122. if(rc ~= 0) then goto quit
  123.  
  124. address(thorport)
  125.  
  126. if(bbs ~= MSG.BBSNAME) then
  127.     PACKEVENTS '"'bbs'"'
  128.  
  129. exit
  130.  
  131. quit:
  132.     address(thorport)
  133.     REQUESTNOTIFY TEXT '"'BBSREAD.LASTERROR'"' BT '"_Ok"'
  134.     exit
  135.